<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box p {
        height: 300px;
        font-size: 3rem;
        display: flex;
        justify-content: center;
        align-items: center;
        border: solid;
      }
    </style>
  </head>
  <body>
    <div id="box">
      <p>p1</p>
      <p>p2</p>
      <p>p3</p>
      <p>p4</p>
      <p>p5</p>
      <p>p6</p>
    </div>
    <script>
      window.onscroll = function (e) {
        const h1 = document.documentElement.scrollHeight;
        const h2 = window.pageYOffset;
        const h3 = window.innerHeight;
        // 判断触底
        if (h1 - h2 - h3 < 60) {
          // 添加新内容
          const p = document.createElement("p");
          p.innerHTML = "new P";
          box.append(p);
        }
      };
    </script>
  </body>
</html>
